using System.Diagnostics;
using NLog;

namespace sgf.server
{
    public static class LogMgr
    {
        private static Logger _logger = null!;

        public static void Init()
        {
            LogManager.Configuration = new NLog.Config.XmlLoggingConfiguration("../Config/Nlog/NLog.config");
            // LogManager.Configuration.Variables["appIdFormat"] = $"{process:000000}";
            // LogManager.Configuration.Variables["currentDir"] = Environment.CurrentDirectory;
            _logger = LogManager.GetLogger("Server");
        }

        public static void Trace(string message)
        {
            _logger.Trace(message);
        }

        public static void Warning(string message)
        {
            _logger.Warn(message);
        }

        public static void Info(string message)
        {
            _logger.Info(message);
        }

        public static void Debug(string message)
        {
            _logger.Debug(message);
        }

        public static void Error(string message)
        {
            StackTrace st = new StackTrace(2, true);
            _logger.Error(message + "\n" + st);
        }

        public static void Fatal(string message)
        {
            _logger.Fatal(message);
        }

        public static void Trace(string message, params object[] args)
        {
            _logger.Trace(message, args);
        }

        public static void Warning(string message, params object[] args)
        {
            _logger.Warn(message, args);
        }

        public static void Info(string message, params object[] args)
        {
            _logger.Info(message, args);
        }

        public static void Debug(string message, params object[] args)
        {
            _logger.Debug(message, args);
        }

        public static void Error(string message, params object[] args)
        {
            _logger.Error(message, args);
        }

        public static void Fatal(string message, params object[] args)
        {
            _logger.Fatal(message, args);
        }
    }
}